<template>
  <div>
    <el-container>
      <el-header class="layout-header" style="background-color: #2c3e50">
        <h1 style="font-size: 22px;color: white">
          泊客湾酒店后台管理系统
          <span style="float: right;font-size: 15px">
            <a @click="logout()">退出登录</a>
          </span>
        </h1>
      </el-header>
      <el-container class="layout-body">
        <el-aside class="layout-aside">
          <el-menu
              router
              :default-active="$router.currentRoute.path"
              class="el-menu-vertical-demo"
              background-color="#222"
              text-color="#fff"
              active-text-color="#ffd04b">
            <el-menu-item index="/index">
              <span>工作台</span>
            </el-menu-item>
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-s-home"></i>
                <span>订单管理</span>
              </template>
              <el-menu-item index="/ol">
                <i class="el-icon-s-goods"></i>
                <span>订单列表</span>
              </el-menu-item>
              <el-menu-item index="/go">
                <i class="el-icon-s-marketing"></i>
                <span>生成订单</span>
              </el-menu-item>
            </el-submenu>
            <el-submenu index="2">
              <template slot="title">
                <i class="el-icon-s-finance"></i>
                <span>客房中心</span>
              </template>
              <el-menu-item index="/rs2">
                <i class="el-icon-s-platform"></i>
                <span>房间类型</span>
              </el-menu-item>
              <el-menu-item index="/ar">
                <i class="el-icon-s-data"></i>
                <span>添加房间</span>
              </el-menu-item>
            </el-submenu>
            <el-submenu index="3">
              <template slot="title">
                <i class="el-icon-s-finance"></i>
                <span>员工管理</span>
              </template>
              <el-menu-item index="/ei">
                <i class="el-icon-circle-plus"></i>
                <span>信息管理</span>
              </el-menu-item>
              <el-menu-item index="/pa">
                <i class="el-icon-circle-plus"></i>
                <span>绩效考核</span>
              </el-menu-item>
              <el-menu-item index="/rm">
                <i class="el-icon-circle-plus"></i>
                <span>角色管理</span>
              </el-menu-item>
              <el-menu-item index="/mm">
                <i class="el-icon-circle-plus"></i>
                <span>菜单管理</span>
              </el-menu-item>
            </el-submenu>
            <el-submenu index="4">
              <template slot="title">
                <i class="el-icon-s-finance"></i>
                <span>数据统计</span>
              </template>
              <el-menu-item index="/or">
                <i class="el-icon-s-data"></i>
                <span>房间入住率</span>
              </el-menu-item>
              <el-menu-item index="/wst">
                <i class="el-icon-s-data"></i>
                <span>工资统计</span>
              </el-menu-item>
            </el-submenu>
            <el-submenu index="5">
              <template slot="title">
                <i class="el-icon-s-home"></i>
                <span>爱心服务</span>
              </template>
              <el-menu-item index="/sl">
                <i class="el-icon-s-goods"></i>
                <span>服务列表</span>
              </el-menu-item>
              <el-menu-item index="/ci">
                <i class="el-icon-s-marketing"></i>
                <span>顾客意见</span>
              </el-menu-item>

            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main class="layout-main">
          <router-view/>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  name: "HomeView",
  data() {
    return {
      activeMenuItemPath: ''
    }
  },
  methods: {
    logout() {
      localStorage.removeItem('jwt')
      this.$router.push({path: '/login'})
      console.log(localStorage.getItem('jwt'));
    }
  },
  mounted() {
    let path = this.$router.currentRoute.path;
    if (path.startsWith('/back/3/ol')) {
      path = '/back/3/OrderList';
    }
    this.activeMenuItemPath = path;
  }
}
</script>

<style scoped>
.layout-header {
  background: cornflowerblue;
  cursor: pointer;
}

.layout-header h1 {
  color: slateblue;
  line-height: 60px;
}

.layout-body {
  position: absolute;
  top: 60px;
  bottom: 0;
  left: 0;
  right: 0;
  float: left;
}

.layout-aside {
  background:#222 ;
}

.layout-aside i {
  color: #fff !important;
}

.layout-main {
  background: #ecf5ff;
}
</style>
